export default {
  data() {
    return {
      pageData: {
        pageNum: 1,
        pageSize: 5,
        totalPages: 0,
        total: 0,
        search: ''
      },
      search: ''
    }
  },
  methods: {
    handleCurrentChange(page) {
      this.pageData.pageNum = page
      this.getCurrentData()
    },
    handleCurrentSizeChange(pagesize) {
      this.pageData.pageNum = 1
      this.pageData.pageSize = pagesize
      this.getCurrentData()
    },
    getPageParams() {
      const params = { pageNum: this.pageData.pageNum, pageSize: this.pageData.pageSize }
      if (this.pageData.search.length !== 0) {
        params.search = this.pageData.search
      }
      return params
    },
    getPageConfig(resp) {
      this.pageData.pageNum = parseInt(resp.data.pageNum)
      this.pageData.pageSize = parseInt(resp.data.pageSize)
      this.pageData.totalPages = parseInt(resp.data.totalPages)
      this.pageData.total = parseInt(resp.data.total)
    },
    // 关于搜索
    getSearchCurrentData() {
      this.pageData.search = this.search
      this.getCurrentData()
    },
    clearSearch() {
      this.pageData.search = ''
      this.search = ''
      this.getCurrentData()
    }
  }
}
